package tech.dongling.boot.common.base;

import cn.hutool.json.JSONObject;

// 统一响应模型
public class ApiResponse {
    private int code;
    private String msg;
    private Object data;

    public ApiResponse() {}
    public ApiResponse(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    // 转为JSON字节数组
    public byte[] toJsonBytes() {
        return new JSONObject(this).toString().getBytes();
    }

    // getter/setter
    public int getCode() { return code; }
    public void setCode(int code) { this.code = code; }
    public String getMsg() { return msg; }
    public void setMsg(String msg) { this.msg = msg; }
    public Object getData() { return data; }
    public void setData(Object data) { this.data = data; }
}